import { NgModule } from '@angular/core'
import { Routes, RouterModule } from '@angular/router'

import { EStoreChannelRouteName } from './new/qrcode-channel/qrcode-channel.interface'
import { NewRouterGuardClass } from '@shared/classes/NewRouterGuardClass'
import { StoreListComponent } from './list/list.component'
import { StoreChannelComponent } from './detail/channel/channel.component'
import { StoreDetailComponent } from './detail/detail.component'
import { StoreDetailTabTerminalComponent } from './detail/tab-terminal/tab-terminal.component'
import { StoreDetailTabQRChannelsComponent } from './detail/tab-qr-channels/tab-qr-channels.component'
import { StoreDetailTabCardChannelsComponent } from './detail/tab-card-channels/tab-card-channels.component'
import { StoreDetailTabECChannelsComponent } from './detail/tab-ec-channels/tab-ec-channels.component'
import { StoreDetailTabSystemComponent } from './detail/tab-system/tab-system.component'
import { StoreDetailTabSettlementComponent } from './detail/tab-settlement/tab-settlement.component'
import { StoreDetailTabUsersComponent } from './detail/tab-users/tab-users.component'
import { StoreDetailTabQRFunctionComponent } from './detail/tab-qr-function/tab-qr-function.component'
import { StoreDetailTabRiskControlComponent } from './detail/tab-risk-control/tab-risk-control.component'
import { StoreNewComponent } from './new/new.component'
import { StoreDetailRouterGuardClass } from '@shared/classes/StoreDetailRouterGuardClass'
import { ListRouterGuardClass } from '@shared/classes/ListRouterGuardClass'
import { ListReuseGuardClass } from '@shared/classes/ListReuseGuardClass'

const routes: Routes = [
  { path: '', redirectTo: 'list', component: StoreListComponent, pathMatch: 'full' },
  {
    path: 'list',
    component: StoreListComponent,
    canActivate: [ListRouterGuardClass, ListReuseGuardClass],
    pathMatch: 'full',
    data: {
      title: '门店列表',
      titleI18n: 'MENU.BIZ.STORES',
      reuse: true,
    },
  },
  {
    path: 'new',
    component: StoreNewComponent,
    canDeactivate: [NewRouterGuardClass],
    data: {
      breadcrumb: 'GENERAL.INFO.BREADCRUMB.CREATE',
      titleI18n: 'BIZ.STORE.TITLE.CREATE',
      routeName: EStoreChannelRouteName.CreateStore,
    }
  },
  {
    path: ':id',
    component: StoreDetailComponent,
    data: { breadcrumb: 'GENERAL.INFO.BREADCRUMB.DETAIL' },
    canDeactivate: [StoreDetailRouterGuardClass],
    children: [
      { path: '', redirectTo: 'terminals', pathMatch: 'full' },
      {
        path: 'terminals',
        component: StoreDetailTabTerminalComponent,
        data: {
          titleI18n: 'BIZ.STORE.TITLE.DETAIL',
        },
      },
      {
        path: 'channels/qr',
        component: StoreDetailTabQRChannelsComponent,
        data: {
          titleI18n: 'BIZ.STORE.TITLE.DETAIL',
        },
      },
      {
        path: 'channels/card',
        component: StoreDetailTabCardChannelsComponent,
        data: {
          titleI18n: 'BIZ.STORE.TITLE.DETAIL',
        },
      },
      {
        path: 'channels/ec',
        component: StoreDetailTabECChannelsComponent,
        data: {
          titleI18n: 'BIZ.STORE.TITLE.DETAIL',
        },
      },
      {
        path: 'system',
        component: StoreDetailTabSystemComponent,
        data: {
          titleI18n: 'BIZ.STORE.TITLE.DETAIL',
        },
      },
      {
        path: 'settlement',
        component: StoreDetailTabSettlementComponent,
        data: {
          titleI18n: 'BIZ.STORE.TITLE.DETAIL',
        },
      },
      // {
      //   path: 'function/qr',
      //   component: StoreDetailTabQRFunctionComponent,
      //   data: {
      //     titleI18n: 'BIZ.STORE.TITLE.DETAIL',
      //   },
      // },
      {
        path: 'rc',
        component: StoreDetailTabRiskControlComponent,
        data: {
          titleI18n: 'BIZ.STORE.TITLE.DETAIL',
        },
      },
      {
        path: 'users',
        component: StoreDetailTabUsersComponent,
        data: {
          titleI18n: 'BIZ.STORE.TITLE.DETAIL',
        },
      },
    ],
  },
  {
    path: ':id/:category/channel',
    component: StoreChannelComponent,
    data: {
      breadcrumb: 'BIZ.STORE.TITLE.OPEN_CHANNEL',
      titleI18n: 'BIZ.STORE.TITLE.OPEN_CHANNEL',
      routeName: EStoreChannelRouteName.OpenChannel,
    },
  },
  {
    path: ':id/:category/channel/:cid',
    component: StoreChannelComponent,
    data: {
      breadcrumb: 'BIZ.STORE.TITLE.EDIT_CHANNEL',
      titleI18n: 'BIZ.STORE.TITLE.EDIT_CHANNEL',
      routeName: EStoreChannelRouteName.EditChannel,
    },
  },
]

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class StoreRoutingModule {}
